package ro.gateway.aida.servlet;

import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import ro.gateway.aida.db.PersistenceManager;
import ro.gateway.aida.db.PersistenceToken;
import ro.gateway.aida.obj.db.OrganizationDB;
import ro.gateway.aida.obj.db.PersonDB;
import ro.gateway.aida.obj.db.SearchDB;
import ro.gateway.aida.srv.EditorServlet;
import ro.gateway.aida.srv.ICFService;
import ro.gateway.aida.usr.User;
import ro.gateway.aida.usr.UserUtils;
import ro.gateway.aida.utils.HttpUtils;



/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (comparator) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0-* @version $Id: OrgList.java,v 1.1 2004/10/24 23:37:16 mihaipostelnicu Exp $
 * @deprecated
 */
public class OrgList extends EditorServlet
{
	  public static final String PNAME_BEANS = "LISTING_ORGS";
	  public static final String PNAME_ACTS = "LISTING_ACTIVITIES";
	  public static final String JSP_PAGE = "orglist.jsp";
	  public static final String PNAME_ERRORS = "errors";
	  public static final String PNAME_ORG_LIST = "ORG_LIST";
	  public static final String PNAME_PERS_LIST = "PERSON_LIST";

	  public OrgList()
	  {
	  }

	  protected void edit( HttpServletRequest request, HttpServletResponse response )
			throws javax.servlet.ServletException, java.io.IOException
	  {
			request.setAttribute( PNAME_SCREEN, PV_SCR_EDIT );
			request.getRequestDispatcher( JSP_PAGE ).forward( request, response );
	  }

	  protected void start_editing( ServletContext application,
									HttpServletRequest request, HttpServletResponse response )
			throws IOException, ServletException
	  {
			super.start_editing( application, request, response );
			PersistenceToken token = PersistenceManager.tokenLookup( application );
			HttpSession session = request.getSession();
			Hashtable beans = ( Hashtable ) session.getAttribute( PNAME_BEANS );
			Hashtable bean = ( Hashtable ) request.getAttribute( PNAME_BEAN );
			String action = ( String ) bean.get( PNAME_ACTION );
			String lang = HttpUtils.getValidTrimedString( request, "lang", "ro" );
			User user = UserUtils.getLogged( request, response );
			ICFService cfService = ( ICFService ) ( ( Hashtable ) application.getAttribute( Constants.SERVICES ) ).get( Constants.SERVICE_CF );

			OrganizationDB orgdb = OrganizationDB.getManager(token);
			PersonDB persdb =PersonDB.getManager(token);
			Vector orgs = null;
			Vector perss = null;
			SearchDB sdb = SearchDB.getManager(token);
			/*
			if ( user != null )
			{
				  sdb.setUserID( user.getId() );
				  res = sdb.advancedSearch();
			}
			else
				  res = new Vector();

			if ( res == null ) res = new Vector();
			if ( orgs == null ) orgs = new Vector();
			if ( perss == null ) perss = new Vector();
			bean.put( PNAME_ACTS, res );
			bean.put( PNAME_ORG_LIST, orgs );
			bean.put( PNAME_PERS_LIST, perss );
			if ( user == null ) bean.put( PNAME_ERRORS, "Access denied" );
			*/
	  }

	  protected void other_action_performed( HttpServletRequest request,
											 HttpServletResponse response, String action )
			throws javax.servlet.ServletException, java.io.IOException
	  {
	  }

	  protected void confirm( HttpServletRequest request,
							  HttpServletResponse response )
			throws javax.servlet.ServletException, java.io.IOException
	  {
			/**@todo Implement this ro.gateway.aida.srv.EditorServlet abstract method*/
	  }

	  public String getPNAME_BEANS()
	  {
			return PNAME_BEANS;
	  }

	  protected void cancel( HttpServletRequest request,
							 HttpServletResponse response ) throws IOException, ServletException
	  {
			super.cancel( request, response );
	  }

	  protected void save( ServletContext application, HttpServletRequest request,
						   HttpServletResponse response )
			throws javax.servlet.ServletException, java.io.IOException
	  {
			/**@todo Implement this ro.gateway.aida.srv.EditorServlet abstract method*/
	  }

	  public String getJSP_PAGE()
	  {
			return JSP_PAGE;
	  }
}
